package com.qian.apiserver.service;

import com.qian.apiserver.model.Config1;
import java.lang.Long;
import com.qian.apiserver.entity.GmConfig1;
import com.qian.apiserver.dao.Config1Dao;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.service.common.BaseRepository;
import java.lang.String;
import com.yaowk.service.common.BaseServiceImpl;
import com.qian.apiserver.service.IConfig1Service;

public abstract class Config1ServiceBase extends BaseServiceImpl<Config1, GmConfig1, Long> implements IConfig1Service {

	@Autowired
	private Config1Dao dao;

	@Override protected Config1Dao getDao() {
	return dao;
	}

	@Override
	protected Config1 entity2model(GmConfig1 entity) {
		Config1 model = null;
		if(isNotEmpty(entity)){
			model = new Config1();
			model.setId(entity.getId());
			model.setType(entity.getType());
			model.setValue(entity.getValue());
			model.setName(entity.getName());
			model.setDescription(entity.getDescription());
			model.setClassName(entity.getClassName());
		}
		return model;
	}

	@Override
	protected GmConfig1 model2Entity(Config1 model) {
		GmConfig1 entity = null;
		if(isNotEmpty(model)){
			entity = new GmConfig1();
			entity.setId(model.getId());
			entity.setType(model.getType());
			entity.setValue(model.getValue());
			entity.setName(model.getName());
			entity.setDescription(model.getDescription());
			entity.setClassName(model.getClassName());
		}
		return entity;
	}

	@Override
	protected GmConfig1 updateParams(Config1 model) {
		GmConfig1 entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getType()))
			entity.setType(model.getType());
		if(isNotEmpty(model.getValue()))
			entity.setValue(model.getValue());
		if(isNotEmpty(model.getName()))
			entity.setName(model.getName());
		if(isNotEmpty(model.getDescription()))
			entity.setDescription(model.getDescription());
		if(isNotEmpty(model.getClassName()))
			entity.setClassName(model.getClassName());
		return entity;
	}


}